//
//  IBlock.m
//  Tetris
//
//  Created by Wei Yeh, Evelyn Yung on 5/7/09.
//

#import "TetrisController.h"

@implementation IBlock

-(id)initAtY:(unsigned int)y x:(unsigned int)x check:(bool)check
{	
	if (![super initAtY:y x:x check:check]) return nil;
	
	myColor = [NSColor redColor];
	[myCells addObject:[myBoard cellAtY:y x:x-2]];
	[myCells addObject:[myBoard cellAtY:y x:x-1]];
	[myCells addObject:[myBoard cellAtY:y x:x]];
	[myCells addObject:[myBoard cellAtY:y x:x+1]];
	
	return self;
}

-(NSMutableArray *)transform:(BOOL)check 
{
	int arrX[]= {0,0,0,0};
	int arrY[] = {0,0,0,0};
	if (myRotationCount == 0) {
		arrX[0] = 1;
		arrY[0] = 1;

		arrX[2] = -1;
		arrY[2] = -1;
		
		arrX[3] = -2;
		arrY[3] = -2;
		if (!check) myRotationCount++;
	} else {
		arrX[0] = -1;
		arrY[0] = -1;
		
		arrX[1] = 0;
		arrY[1] = 0;
		
		arrX[2] = 1;
		arrY[2] = 1;
		
		arrX[3] = 2;
		arrY[3] = 2;
		if (!check) myRotationCount = 0;
	}
	
	return [self moveByArrayY:arrY arrayX:arrX];
}

@end
